package com.x.erp.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.MultilevelActivityDao;
import com.x.erp.manage.MultilevelActivityManage;
import com.x.erp.model.MultilevelActivity;
import com.x.erp.rpc.MultilevelActivityRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 多级营销活动服务
 */
@Component
@Service(interfaceName = "com.x.erp.rpc.MultilevelActivityRpcService", timeout = 60000)
public class MultilevelActivityService extends BaseService implements MultilevelActivityRpcService {

	@Autowired
	private MultilevelActivityDao multilevelActivityDao;//多级营销活动信息DAO

	@Autowired
	private MultilevelActivityManage multilevelActivityManage;//多级营销活动信息Manage

	/**
	 * 查询多级营销活动列表
	 * @param multilevelActivity
	 * @return
	 */
	@Override
	public List<MultilevelActivity> selectMultilevelActivityList(MultilevelActivity multilevelActivity){
		try {
			return multilevelActivityDao.selectMultilevelActivityList(multilevelActivity);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 查询多级营销活动数量
	 * @param multilevelActivity
	 * @return
	 */
	@Override
	public int selectMultilevelActivityNum(MultilevelActivity multilevelActivity){
		try {
			return multilevelActivityDao.selectMultilevelActivityNum(multilevelActivity);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 新增多级营销活动信息
	 * @param multilevelActivity
	 * @return
	 */
	@Override
	public MultilevelActivity insertMultilevelActivity(MultilevelActivity multilevelActivity){
		try {
			return multilevelActivityManage.insertMultilevelActivity(multilevelActivity);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 修改多级营销活动信息
	 * @param multilevelActivity
	 * @return
	 */
	@Override
	public int updateMultilevelActivity(MultilevelActivity multilevelActivity){
		try {
			return this.update(multilevelActivity);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

}
